//package com.example.crud.api;
//
//import cn.hutool.core.util.StrUtil;
//import com.addzero.common.core.api_api_impl_version.BaseApiImpl;
//import com.addzero.common.util.easyexcel.EasyExcelWriteUtil;
//import com.example.crud.assembler.WitnessRecordConvert;
//import com.example.crud.po.DelegationOrder;
//import com.example.crud.po.DelegationOrder2DTO;
//import com.example.crud.po.WitnessRecord;
//import com.example.crud.service.WitnessRecordService;
//import com.example.crud.vo.in.WitnessRecordConditionInVO;
//import com.example.crud.vo.in.WitnessRecordInVO;
//import com.example.crud.vo.out.WitnessRecordOutVO;
//import com.github.houbb.data.factory.core.util.DataUtil;
//import lombok.SneakyThrows;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.UnsupportedEncodingException;
//import java.net.URLEncoder;
//import java.util.List;
//
///**
// * 见证记录(WitnessRecord)表控制层
// *
// * @author addzero
// * @since 2022-11-27 15:38:00
// */
//@RestController
//
//public class WitnessRecordApiImpl extends BaseApiImpl<
//        WitnessRecordService,
//        WitnessRecordConvert,
//        WitnessRecordConditionInVO
//        , WitnessRecordInVO
//        , WitnessRecordOutVO
//        , WitnessRecord
//        >
//        implements  WitnessRecordApi{
//
//    @Override
//    public void generateWitnessRecords(HttpServletResponse response) {
//
//        WitnessRecord build1 = DataUtil.build(WitnessRecord.class);
//        //取样日期
//
//        String samplingDate = build1.getSamplingDate().toString();
//
//        //样品名称
//        String sampleName = build1.getSampleName();
//        //楼号
//        String buildingNo = build1.getBuildingNo();
//
//        //取样部位
//        String samplingPosition = build1.getSamplingPosition();
//
//        String fileName = StrUtil.join("_", samplingDate, sampleName, buildingNo, samplingPosition)+".xlsx";;
//
//        //samplingDate.
//        //String sampleName = build.getSampleName();
//        //build.getProjectName()
//        String temPath = "templates/见证记录模板.xlsx";
//        EasyExcelWriteUtil.templateFill(response, build1, temPath, fileName);
//
//    }
//
//
//    @Override
//    public void generatePowerOfAttorney(HttpServletResponse response) {
//
//        DelegationOrder build = DataUtil.build(DelegationOrder.class);
//        //委托
//        String samplingDate = build.getDateOfEntrustment().toString();
//
//        //样品名称
//        String sampleName = build.getSampleName();
//        //楼号
//        String buildingNo = build.getBuildingNo();
//        List<DelegationOrder2DTO> delegationOrder2DTOS = build.getDelegationOrder2DTOS();
//        delegationOrder2DTOS.forEach(e-> {
//            e.setSampleState("□正常□异常");
//            e.setCommissionNumber(null);
//        });
////工程部位
//        String siteOfEngineering = delegationOrder2DTOS.stream().map(DelegationOrder2DTO::getProjectPosition).findAny().orElse("");
//
//        String fileName = StrUtil.join("_", samplingDate, sampleName, buildingNo, siteOfEngineering)+".xlsx";
//
//        //samplingDate.
//        //String sampleName = build.getSampleName();
//        //build.getProjectName()
//        String temPath = "templates/委托单模板.xlsx";
//        EasyExcelWriteUtil.templateFill(response, build,delegationOrder2DTOS ,temPath, fileName);
//    }
//
//    @SneakyThrows(UnsupportedEncodingException.class)
//    private HttpServletResponse getHttpServletResponse(HttpServletResponse response, final String s) {
//        response.setContentType("application/octet-stream");
//        response.setHeader("content-type", "application/octet-stream");
//        response.setCharacterEncoding("utf-8");
//        // 这里URLEncoder.encode可以防止中文乱码
//        String fileName = URLEncoder.encode(s, "UTF-8").replaceAll("\\+", "%20");
//        response.setHeader("Content-disposition", "attachment;filename=" + fileName);
//        return response;
//
//    }
//
//}
